using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_Sys_RoleAuthorityList", "ID", "Torch.WL.ConnectionString")]
	public class Tb_Sys_RoleAuthorityList : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_ID = "ID";
		public const string SQLCOL_USERID = "UserID";
		public const string SQLCOL_ROLEID = "RoleID";
		public const string SQLCOL_MODULEID = "ModuleID";
		public const string SQLCOL_AUTHORITYTAG = "AuthorityTag";
		public const string SQLCOL_FLAG = "Flag";
		public const string SQLCOL_USERNAME = "Username";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Tb_Sys_RoleAuthorityList () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Tb_Sys_RoleAuthorityList (int ID)
		{
			this.ID = ID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			ID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ID]);
			UserID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_USERID]);
			RoleID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ROLEID]);
			ModuleID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_MODULEID]);
			AuthorityTag = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_AUTHORITYTAG]);
			Flag = (bool)ObjectType.BooleanTypeHelper.Read(row[SQLCOL_FLAG]);
			Username = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_USERNAME]);
		}

		#region Properties 
		#region Property <int> ID
		[Property("ID", 4, SqlDbType.Int, true, true)]
		public int ID 
		{
			get { return _ID; }
			set { _ID = value; }
		}
		private int _ID = int.MinValue;
		#endregion

		#region Property <int> UserID
		[Property("UserID", 4, SqlDbType.Int, false, false)]
		public int UserID 
		{
			get { return _UserID; }
			set { _UserID = value; }
		}
		private int _UserID = int.MinValue;
		#endregion

		#region Property <int> RoleID
		[Property("RoleID", 4, SqlDbType.Int, false, false)]
		public int RoleID 
		{
			get { return _RoleID; }
			set { _RoleID = value; }
		}
		private int _RoleID = int.MinValue;
		#endregion

		#region Property <int> ModuleID
		[Property("ModuleID", 4, SqlDbType.Int, false, false)]
		public int ModuleID 
		{
			get { return _ModuleID; }
			set { _ModuleID = value; }
		}
		private int _ModuleID = int.MinValue;
		#endregion

		#region Property <string> AuthorityTag
		[Property("AuthorityTag", 100, SqlDbType.NVarChar, false, false)]
		public string AuthorityTag 
		{
			get { return _AuthorityTag; }
			set { _AuthorityTag = value; }
		}
		private string _AuthorityTag = null;
		#endregion

		#region Property <bool> Flag
		[Property("Flag", 1, SqlDbType.Bit, false, false)]
		public bool Flag 
		{
			get { return _Flag; }
			set { _Flag = value; }
		}
		private bool _Flag = false;
		#endregion

		#region Property <string> Username
		[Property("Username", 50, SqlDbType.VarChar, false, false)]
		public string Username 
		{
			get { return _Username; }
			set { _Username = value; }
		}
		private string _Username = null;
		#endregion
		#endregion


		public bool LoadByIdentity(int ID)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(ID));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
